package com.online.onlineshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.online.onlineshop.entity.OrderItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface OrderItemMapper extends BaseMapper<OrderItem> {
    @Insert("<script>" +
            "INSERT INTO t_order_item (\n" +
            "oid, pid, title, image, price, num, created_user,\n" +
            "created_time, modified_user, modified_time\n" +
            ") VALUES (\n" +
            "#{oid}, #{pid}, #{title}, #{image}, #{price}, #{num}, #\n" +
            "#{createdUser},\n" +
            "#{createdTime}, #{modifiedUser}, #{modifiedTime}\n" +
            ")\n" +
            "</script>")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    Integer insertOrderItems(OrderItem orderItem);
}
